package cn.tedu.ivos.dictoption.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.dictoption.pojo.dto.DictOptionQuery;
import cn.tedu.ivos.dictoption.pojo.dto.DictOptionSaveParam;
import cn.tedu.ivos.dictoption.pojo.vo.DictOptionVO;
import cn.tedu.ivos.dictoption.servie.DictOptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/v1/dictOption/")
public class DictOptionController {

    @Autowired
    private DictOptionService service;

    @GetMapping("select")
    public JsonResult select(DictOptionQuery dictOptionQuery) {
        List<DictOptionVO> list = service.select(dictOptionQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult save(DictOptionSaveParam dictOptionSaveParam) {
        service.save(dictOptionSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("del/{id}")
    public JsonResult del(@PathVariable Long id) {
        service.del(id);
        return JsonResult.ok();
    }


    @GetMapping("select/{code}")
    public JsonResult selectDictOptionByDictCode(@PathVariable String code)
    {
        log.debug("根据字典code查询字典项{}",code);
        List<DictOptionVO> list =  service.selectDictOptionByDictCode(code);
        return JsonResult.ok(list);

    }



























}
